Repository navigation
fix(dev): declare an empty source map for route chunk placeholders when an export can't be split - #15520
Open
huuyafwww wants to merge 2 commits into
Open
fix(dev): declare an empty source map for route chunk placeholders when an export can't be split#15520huuyafwww wants to merge 2 commits into
huuyafwww wants to merge 2 commits into
Conversation
…en an export can't be split
The placeholder `react-router:split-route-modules` returns for a
`?route-chunk=` entry whose export turned out not to be splittable was
still a plain string, so with `build.sourcemap` enabled Rollup warned
that the plugin dropped the source map. It now returns the same
`map: { mappings: "" }` shape that remix-run#15440 uses for the route barrel.
The existing source map test looked for the `SOURCEMAP_BROKEN` code,
which Vite never prints, so it checks the message text now, and a new
test covers the placeholder path on both Vite templates.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi. While looking at the source map handling that #15440 added to the route module transforms, I noticed one path still returns a plain string: the placeholder that
react-router:split-route-modulesemits for a?route-chunk=entry whose export turned out not to be splittable (or when splitting is disabled). Withbuild.sourcemapenabled on Vite 7, Rollup reports this for every such route:This returns the placeholder with
map: { mappings: "" }, the same shape #15440 used for the generated route barrel, so Rollup knows there is nothing to map back to. rolldown doesn't warn either way, so nothing changes on Vite 8.The existing "emits source maps for split route chunks" test asserted that stderr doesn't contain
SOURCEMAP_BROKEN, but Vite prints the message without the code, so that check couldn't fail; it now looks for the message text. The new test builds a route whoseclientLoadershares a top-level variable with the default export, so it can't be split, withsourcemap: true, and checks that the placeholder chunk is emitted without the warning. It fails onmainwith the Vite 7 template and passes here on both templates. Typecheck, lint, format,changes:validateand the split-route-modules integration suite are green on Chromium.